<template>
  <div>
    <!-- 视频课程 -->

    <!-- 顶部链接条 -->
    <div class="subnav-hot-main">
      <div class="subnav-hot-video warp">
        <div class="subnav-hot-video-row">
          <div class="row-title">初中</div>
          <ul class="nav-row-content">
            <li><span class=""> 初中视频大全 </span></li>
            <li><span class=""> 初中语文视频 </span></li>
            <li><span class=""> 初中数学视频 </span></li>
            <li><span class=""> 初中英语视频 </span></li>
            <li><span class=""> 初中政治视频 </span></li>
            <li><span class=""> 初中历史视频 </span></li>
            <li><span class=""> 初中地理视频 </span></li>
            <li><span class=""> 初中物理视频 </span></li>
            <li><span class=""> 初中化学视频 </span></li>
            <li><span class=""> 初中生物视频 </span></li>
            <li><span class=""> 初中学习方法 </span></li>
          </ul>
        </div>
        <div class="line mb-20"></div>
        <div class="subnav-hot-video-row">
          <div class="row-title">高中</div>
          <ul class="nav-row-content">
            <li><span class=""> 高中视频大全 </span></li>
            <li><span class=""> 高中语文视频 </span></li>
            <li><span class=""> 高中数学视频 </span></li>
            <li><span class=""> 高中英语视频 </span></li>
            <li><span class=""> 高中政治视频 </span></li>
            <li><span class=""> 高中历史视频 </span></li>
            <li><span class=""> 高中地理视频 </span></li>
            <li><span class=""> 高中物理视频 </span></li>
            <li><span class=""> 高中化学视频 </span></li>
            <li><span class=""> 高中生物视频 </span></li>
            <li><span class=""> 高中学习方法 </span></li>
          </ul>
        </div>
      </div>
    </div>
    <!-- 顶部链接条 END-->

    <!-- 视频条 -->
    <div class="warp">
      <div class="main-video mt-20">
        <!-- 左侧视频条 -->

        <div class="main-video-left">
          <div v-if="CourseVideoLists">
            <div
              class="main-video-li"
              v-for="item in CourseListsFun()"
              :key="item.CVids"
              @click="setkeys(item.CVkey, item.CVids)"
            >
              <div class="li">
                <div class="img-body">
                  <img :src="item.imgs" :alt="item.title" />
                  <span class="dis-block">{{ item.duration }}</span>
                </div>
                <div data-v-1ab57be6="">
                  <p class="main-video-title">
                    <span class="text"> {{ item.title }} </span>
                  </p>
                  <p class="main-video-contant">{{ item.texts }}</p>
                  <p class="main-video-footer">
                    <span>{{ item.times }}</span>
                    <span>
                      <i class="iconfont icon-view"></i>
                      {{ item.num }}人学习
                    </span>
                  </p>
                </div>
              </div>
            </div>
          </div>

          <!-- 分页条 -->

          <ul class="app-pagination">
            <li @click="pagefirst">
              <span> 首页 </span>
            </li>
            <li @click="pageup">
              <span> 上一页 </span>
            </li>
            <li
              :class="[tpyes == count ? 'active' : '']"
              v-for="count in pages"
              :key="count"
              @click="pageFun(count)"
            >
              <span> {{ count }} </span>
            </li>
            <li @click="pagedown">
              <span> 下一页 </span>
            </li>
            <li @click="pagelast">
              <span> 尾页 </span>
            </li>
            <li class="total">
              <p href="javascript:void(0)">共 {{ pages }} 条</p>
            </li>
          </ul>

          <!-- 分页条 END-->
        </div>

        <!-- 左侧视频条 END-->

        <!-- 右侧导航条 -->

        <div class="main-video-right">
          <div class="study-tools bg-white default-border">
            <div class="sidebar">
              <h3>学习工具</h3>
            </div>
            <div class="tools-content">
              <router-link to="/appdown" class="">
                <div class="tools-item">
                  <div class="item-icon icon iconfont icon-app"></div>
                  <div class="intro">APP下载</div>
                </div>
              </router-link>
              <router-link to="/appdown" class="">
                <div class="tools-item">
                  <div class="item-icon icon iconfont icon-book"></div>
                  <div class="item-intro">5000+课程</div>
                </div>
              </router-link>
            </div>
          </div>
          <div class="main-video-recommend mt-10">
            <div class="title">
              <h4>推荐内容</h4>
            </div>
            <ul class="main-video-recommend-ul">
              <router-link to="/course" class="li dis-block"
                ><img
                  src="https://img.yixuela.com/1648736502783.jpg"
                  alt="高中数学解析几何专题教学视频"
                />
                <div class="recommend-ul-info">
                  <p class="recommend-ul-title">高中数学解析几何专题教学视频</p>
                  <p class="recommend-ul-i">
                    <span><i class="iconfont icon-time"></i> 16时39分</span>
                    <span><i class="iconfont icon-view"></i> 61016人学习</span>
                  </p>
                </div>
              </router-link>

              <router-link to="/course" class="li dis-block"
                ><img
                  src="https://img.yixuela.com/1648653900829.jpg"
                  alt="高中数学立体几何专题教学视频"
                />
                <div class="recommend-ul-info">
                  <p class="recommend-ul-title">高中数学立体几何专题教学视频</p>
                  <p class="recommend-ul-i">
                    <span><i class="iconfont icon-time"></i> 16时9分</span>
                    <span><i class="iconfont icon-view"></i> 36398人学习</span>
                  </p>
                </div>
              </router-link>

              <a href="/video/course/360.html" class="li dis-block"
                ><img
                  src="https://img.yixuela.com/1648567054320.jpg"
                  alt="高中数学不等式专题教学视频"
                />
                <div class="recommend-ul-info">
                  <p class="recommend-ul-title">高中数学不等式专题教学视频</p>
                  <p class="recommend-ul-i">
                    <span><i class="iconfont icon-time"></i> 5时13分</span>
                    <span><i class="iconfont icon-view"></i> 21704人学习</span>
                  </p>
                </div>
              </a>
              <a href="/video/course/359.html" class="li dis-block"
                ><img
                  src="https://img.yixuela.com/1648564586548.jpg"
                  alt="高中数学数列专题教学视频"
                />
                <div class="recommend-ul-info">
                  <p class="recommend-ul-title">高中数学数列专题教学视频</p>
                  <p class="recommend-ul-i">
                    <span><i class="iconfont icon-time"></i> 5时31分</span>
                    <span><i class="iconfont icon-view"></i> 20845人学习</span>
                  </p>
                </div>
              </a>
              <a href="/video/course/358.html" class="li dis-block"
                ><img
                  src="https://img.yixuela.com/1647575611845.jpg"
                  alt="人教版高中历史中外历史纲要下教学视频课程"
                />
                <div class="recommend-ul-info">
                  <p class="recommend-ul-title">
                    人教版高中历史中外历史纲要下教学视频课程
                  </p>
                  <p class="recommend-ul-i">
                    <span><i class="iconfont icon-time"></i> 10时2分</span>
                    <span><i class="iconfont icon-view"></i> 28973人学习</span>
                  </p>
                </div>
              </a>
              <div class="jd-ad">
                <div class="ads-info">
                  <div class=""></div>
                </div>
              </div>
            </ul>
          </div>
        </div>

        <!-- 右侧导航条 END-->
      </div>
    </div>
    <!-- 视频条 END-->
  </div>
</template>

<script>
import { getJsonData } from "../api/home.js";
export default {
  data() {
    return {
      CourseVideoLists: null, //课程视频列表
      pages: 0, //页总数
      index: 0, //页码
      tpyes: 1, //激发态
    };
  },
  methods: {
    getCourseVideoListsFun() {
      //获取课程视频
      getJsonData().then((data) => {
        this.CourseVideoLists = data["CourseVideoLists"];
        console.log(this.CourseVideoLists);
      });
    },
    setkeys(keys, ids) {
      localStorage.setItem("videokey", keys);
      localStorage.setItem("Videoids", ids);
      this.$router.push("course");
      return;
    },
    // 分页功能
    CourseListsFun() {
      let num = 2; //数据数量
      this.pages = Math.ceil(this.CourseVideoLists.length / num); //页总数
      return this.CourseVideoLists.slice(this.index, this.index + num);
    },
    pagedown() {
      if (this.index < this.pages-1) {
        this.tpyes += 1;
        this.index += 1;
      }
    },
    pagelast() {
      this.index = this.pages-1;
      this.tpyes = this.pages;
    },
    pagefirst() {
      this.index = 0;
      this.tpyes = 1;
    },
    pageFun(pages) {
      console.log(pages);
      this.index = pages - 1;
      this.tpyes = pages;
    },
    pageup() {
      if (this.index > 0) {
        this.tpyes -= 1;
        this.index -= 1;
      }
    },
  },
  created() {
    this.getCourseVideoListsFun();
  },
  watch: {
    index: function () {
      this.CourseListsFun();
    },
  },
};
</script>

<style lang="scss" scoped>
.subnav-hot-main {
  width: 100%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 0;
  .subnav-hot-video-row {
    display: flex;
    .row-title {
      font-size: 16px;
      font-weight: 600;
      color: #f76447;
      background: rgba(247, 100, 71, 0.14902);
      border-radius: 4px;
      padding: 0 12px;
      height: 32px;
      line-height: 32px;
      width: 60px;
      text-align: center;
      cursor: pointer;
    }
    .nav-row-content {
      padding: 5px 0;
      font-size: 14px;
      font-weight: 400;
      color: #333;
      span {
        &:hover {
          color: #48c5a3;
          cursor: pointer;
        }
      }
      li {
        margin: 0 0 18px 54px;
      }
    }
  }
}
.line {
  width: 100%;
  height: 1px;
  background-color: #eee;
}
/* 视频条 */
.main-video {
  display: flex;
  justify-content: space-between;
  .main-video-left {
    width: 860px;
  }
  .main-video-right {
    width: 320px;
    .main-video-recommend {
      background: #fff;
      border-radius: 6px;
      padding: 0 17px;
      margin-bottom: 100px;
    }
    .title {
      padding: 15px 0;
      display: flex;
      justify-content: space-between;
    }
    h4 {
      font-size: 18px;
      font-weight: 600;
      color: #333;
      line-height: 25px;
    }
    .main-video-user {
      background: #fff;
      border-radius: 6px;
      padding: 0 17px;
      margin-bottom: 100px;
    }
  }
}
.main-video-li {
  width: 800px;
  height: 200px;
  background: #fff;
  padding: 0 20px;
  color: #333;
  margin-bottom: 20px;
  border-radius: 6px;
  box-shadow: 0 0 24px 0 rgb(0 0 0 / 6%);
  .li {
    height: 100%;
    width: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
  }
  .img-body {
    position: relative;
    margin-right: 20px;
    span {
      position: absolute;
      right: 7px;
      bottom: 10px;
      padding: 1px 6px;
      font-size: 12px;
      font-weight: 400;
      color: #fff;
      background: rgba(0, 0, 0, 0.54902);
      border-radius: 4px;
    }
  }
  img {
    width: 160px;
    height: 160px;
    border-radius: 6px;
  }
  .main-video-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 22px;
    display: flex;
    align-items: flex-start;
    .text {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      max-width: 540px;
      display: inline-block;
    }
  }
  .main-video-contant {
    font-size: 14px;
    font-weight: 400;
    color: #666;
    line-height: 26px;
    width: 540px;
    height: 55px;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 9px 0 20px;
  }
  .main-video-footer {
    font-size: 12px;
    font-weight: 400;
    color: #999;
    line-height: 17px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    padding-right: 20px;
    span {
      margin-right: 30px;
    }
  }
}
/* 右侧导航条 */
.study-tools {
  .sidebar {
    border-bottom: 1px solid #eee;
  }
  .tools-content {
    display: flex;
    justify-content: space-around;
    padding: 20px;
    .tools-item {
      .item-icon {
        font-size: 48px;
      }
      .item-intro {
        margin-top: 5px;
        font-size: 14px;
      }
    }
  }
}
.sidebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  h3 {
    padding: 10px;
    font-size: 18px;
    font-weight: 600;
  }
}
.main-video-right {
  .main-video-recommend {
    .main-video-recommend-ul {
      .li {
        display: flex;
        align-items: center;
        padding: 17px 0;
        border-top: 1px solid #eee;
        img {
          border-radius: 4px;
          width: 80px;
          height: 80px;
        }
      }
      .recommend-ul-info {
        margin-left: 10px;
      }
      .recommend-ul-title {
        font-size: 14px;
        font-weight: 600;
        color: #333;
        line-height: 20px;
      }
      .recommend-ul-i {
        display: flex;
        margin-top: 8px;
        span {
          font-size: 12px;
          font-weight: 400;
          color: #999;
        }
      }
    }
  }
}
.main-video-recommend {
  .main-video-recommend-ul {
    .li {
      span {
        font-weight: 400;
        line-height: 20px;
        display: inline-block;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        width: 83px;
      }
    }
  }
}
/* 分页条 */
.app-pagination {
  margin: 40px auto;
  text-align: center;
  li {
    display: inline-block;
    margin: 0 6px;
    cursor: pointer;
    span {
      padding: 5px 10px;
      display: inline-block;
      color: #626262;
      background: #fff;
      border-radius: 2px;
      border: 1px solid #ddd;
      cursor: pointer;
    }
  }
}
.app-pagination li .active-link,
.app-pagination li.active span,
.app-pagination li span:hover {
  color: #fff;
  border: 1px solid #48c5a3;
  background: #48c5a3;
}
</style>